package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.DataStatisticsSummary;
import com.hello.system.service.IDataStatisticsSummaryService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 数据统计汇总Controller
 * 
 * @author hello
 * @date 2025-09-09
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/dataStatisticsSummary")
public class DataStatisticsSummaryController extends BaseController
{
    private final IDataStatisticsSummaryService dataStatisticsSummaryService;

    /**
     * 查询数据统计汇总列表
     */
    @RequiresPermissions("system:dataStatisticsSummary:list")
    @GetMapping("/list")
    public TableDataInfo list(DataStatisticsSummary dataStatisticsSummary)
    {
        startPage();
        List<DataStatisticsSummary> list = dataStatisticsSummaryService.selectDataStatisticsSummaryList(dataStatisticsSummary);
        return getDataTable(list);
    }

    /**
     * 导出数据统计汇总列表
     */
    @RequiresPermissions("system:dataStatisticsSummary:export")
    @Log(title = "数据统计汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataStatisticsSummary dataStatisticsSummary)
    {
        List<DataStatisticsSummary> list = dataStatisticsSummaryService.selectDataStatisticsSummaryList(dataStatisticsSummary);
        ExcelUtil<DataStatisticsSummary> util = new ExcelUtil<DataStatisticsSummary>(DataStatisticsSummary.class);
        util.exportExcel(response, list, "数据统计汇总数据");
    }

    /**
     * 获取数据统计汇总详细信息
     */
    @RequiresPermissions("system:dataStatisticsSummary:query")
    @GetMapping(value = "/{summaryId}")
    public AjaxResult getInfo(@PathVariable("summaryId") Long summaryId)
    {
        return success(dataStatisticsSummaryService.selectDataStatisticsSummaryBySummaryId(summaryId));
    }

    /**
     * 新增数据统计汇总
     */
    @RequiresPermissions("system:dataStatisticsSummary:add")
    @Log(title = "数据统计汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataStatisticsSummary dataStatisticsSummary)
    {
        return toAjax(dataStatisticsSummaryService.insertDataStatisticsSummary(dataStatisticsSummary));
    }

    /**
     * 修改数据统计汇总
     */
    @RequiresPermissions("system:dataStatisticsSummary:edit")
    @Log(title = "数据统计汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataStatisticsSummary dataStatisticsSummary)
    {
        return toAjax(dataStatisticsSummaryService.updateDataStatisticsSummary(dataStatisticsSummary));
    }

    /**
     * 删除数据统计汇总
     */
    @RequiresPermissions("system:dataStatisticsSummary:remove")
    @Log(title = "数据统计汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{summaryIds}")
    public AjaxResult remove(@PathVariable Long[] summaryIds)
    {
        return toAjax(dataStatisticsSummaryService.deleteDataStatisticsSummaryBySummaryIds(summaryIds));
    }
}
